//意见反馈详情
interface IopinionFeedbackDetailViewModel extends ng.IScope {
    // /**
    //  * 附件上传组件
    //  */
    // attachmentUploader: any;
    /**
     * 反馈标题
     */
    title:string;
    /**
     * 反馈人姓名
     */
    name:string;
    /**
     * 反馈时间
     */
    time:string;
    /**
     * 反馈内容
     */
    content:string;
    /**
     * 反馈图片
     */
    attachmentList:any
    imgSrcArr:any

    /**
     * 返回列表
     */
    backUrl:() => void;  

     /**
     * 点击图片时候触发，用以旋转放大图片
     */
    handleImgClick:(item:any)=>void;
    /**
     * 用以旋转放大的图片的路径
     */
    selectedImgSrc:string;

    attachUploader:any;
}


class OpinionFeedbackDetailController {
    /**
     * 意见反馈信息的id
     */
    opinionFeedbackId: string;

    /**
     * 附件数组
     */
    uploaderList:Array<attachmentList>;
    baseImageUrl: string;


    constructor(private $scope: IopinionFeedbackDetailViewModel, private routeService: routeService, private $http: ng.IHttpService, private $ngBootbox: BootboxService,
        private operationService: IOperationService, private $state: angular.ui.IStateService, private $location: ng.ILocationService, 
        private commonService: ICommonService, private $q: ng.IQService,private ossUploaderService:ossUploaderService) {

        //附件配置
        this.baseImageUrl = this.routeService.getBaseUrl() + "attachment/";
        this.uploaderList = [];
        this.init();
    }

    init(): void {
        this.opinionFeedbackId = this.$location.search().opinionFeedBackId;
        this.loadData()
        this.$scope.backUrl=this.backUrl;
        this.$scope.handleImgClick=(item)=>{this.$scope.selectedImgSrc=item.imgSrc;}

        const OssFile = this.ossUploaderService.getOssFile();

        this.$scope.attachUploader =new OssFile(this.$scope,this.$scope.attachUploader,{uploaderList:this.uploaderList,tag:1,multiple:true});

    }

    loadData = () => {
        this.$scope.attachmentList = [];
        this.operationService.getOpinionDetail(this.opinionFeedbackId).then(res=>{
            this.$scope.title = res.data.title;
            this.$scope.name = res.data.feedBackName;
            this.$scope.time=res.data.creationTime;
            this.$scope.content = res.data.content;
           
            res.data.attachment.forEach((item,index)=>{
               
                this.$scope.attachUploader.addByAttach(item)
            });

            
        })
    }



    //返回事件
    backUrl(): void {
        this.$state.go("app.opera.opinion_feedback");
    }


}


angular.module("tms").controller("OpinionFeedbackDetailController", ["$scope", "routeService", "$http",  "$ngBootbox", 
"operationService", "$state", "$location", "commonService", "$q","ossUploaderService", OpinionFeedbackDetailController]);